package com.yanfan.interfaces.controller;

import java.util.Arrays;
import java.util.List;
import javax.validation.Valid;
import javax.servlet.http.HttpServletResponse;
import com.yanfan.common.utils.DateUtils;
import com.yanfan.common.utils.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yanfan.common.annotation.Log;
import com.yanfan.common.core.controller.BaseController;
import com.yanfan.common.core.domain.AjaxResult;
import com.yanfan.common.enums.BusinessType;
import com.yanfan.interfaces.domain.IbmsInterfaceMonitoringStatistics;
import com.yanfan.interfaces.service.IIbmsInterfaceMonitoringStatisticsService;
import com.yanfan.common.utils.poi.ExcelUtil;
import com.yanfan.common.core.page.TableDataInfo;

/**
 * 接口监测统计Controller
 *
 * @author genluo
 * @date 2024-08-27
 */
@Api(tags = "接口监测统计")
@RestController
@RequestMapping("/interfaces/interfaceMonitoringStatistics")
public class IbmsInterfaceMonitoringStatisticsController extends BaseController {
    @Autowired
    private IIbmsInterfaceMonitoringStatisticsService ibmsInterfaceMonitoringStatisticsService;

    /**
     * 查询接口监测统计列表
     */
    @ApiOperation("接口监测统计分页列表")
    @PreAuthorize("@ss.hasPermi('interfaces:interfaceMonitoringStatistics:list')")
    @GetMapping("/list")
    public TableDataInfo list(IbmsInterfaceMonitoringStatistics ibmsInterfaceMonitoringStatistics) {
        startPage();
        List<IbmsInterfaceMonitoringStatistics> list = ibmsInterfaceMonitoringStatisticsService.queryPageList(ibmsInterfaceMonitoringStatistics);
        return getDataTable(list);
    }

    /**
     * 导出接口监测统计列表
     */
    @ApiOperation("导出接口监测统计列表")
    @PreAuthorize("@ss.hasPermi('interfaces:interfaceMonitoringStatistics:export')")
    @Log(title = "接口监测统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IbmsInterfaceMonitoringStatistics ibmsInterfaceMonitoringStatistics) {
        List<IbmsInterfaceMonitoringStatistics> list = ibmsInterfaceMonitoringStatisticsService.queryPageList(ibmsInterfaceMonitoringStatistics);
        ExcelUtil<IbmsInterfaceMonitoringStatistics> util = new ExcelUtil<IbmsInterfaceMonitoringStatistics>(IbmsInterfaceMonitoringStatistics.class);
        util.exportExcel(response, list, "接口监测统计数据");
    }

    /**
     * 获取接口监测统计详细信息
     */
    @ApiOperation("获取接口监测统计详细信息")
    @PreAuthorize("@ss.hasPermi('interfaces:interfaceMonitoringStatistics:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(ibmsInterfaceMonitoringStatisticsService.getById(id));
    }

    /**
     * 新增接口监测统计
     */
    @ApiOperation("新增接口监测统计")
    @PreAuthorize("@ss.hasPermi('interfaces:interfaceMonitoringStatistics:add')")
    @Log(title = "接口监测统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Valid @RequestBody IbmsInterfaceMonitoringStatistics ibmsInterfaceMonitoringStatistics) {
        return toAjax(ibmsInterfaceMonitoringStatisticsService.save(ibmsInterfaceMonitoringStatistics));
    }

    /**
     * 修改接口监测统计
     */
    @ApiOperation("修改接口监测统计")
    @PreAuthorize("@ss.hasPermi('interfaces:interfaceMonitoringStatistics:edit')")
    @Log(title = "接口监测统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Valid @RequestBody IbmsInterfaceMonitoringStatistics ibmsInterfaceMonitoringStatistics) {
        return toAjax(ibmsInterfaceMonitoringStatisticsService.updateById(ibmsInterfaceMonitoringStatistics));
    }

    /**
     * 删除接口监测统计
     */
    @ApiOperation("删除接口监测统计")
    @PreAuthorize("@ss.hasPermi('interfaces:interfaceMonitoringStatistics:remove')")
    @Log(title = "接口监测统计", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(ibmsInterfaceMonitoringStatisticsService.removeBatchByIds(Arrays.asList(ids)));
    }
}
